Skip to content

update: 更新 LagrangeGo 到最新#38

Merged
Redmomn merged 2 commits intoLagrangeDev:masterfrom
circlecloud:master
Oct 21, 2025
Merged

update: 更新 LagrangeGo 到最新#38
Redmomn merged 2 commits intoLagrangeDev:masterfrom
circlecloud:master

Conversation

@502647092
Copy link
Copy Markdown

  1. 更新兼容了最新版本的 LagrangeGo
  2. 移除了匿名消息相关内容

已编译通过 登录 发送消息 接收消息等基础功能已测试

@Redmomn
Copy link
Copy Markdown
Collaborator

Redmomn commented Oct 21, 2025

需要测试一下获取聊天记录里的图片,视频这类文件正不正常

@502647092
Copy link
Copy Markdown
Author

测试了一下 get_image 提示错误

[2025-10-21 14:35:28] [WARNING]: 获取图片信息: map[filename: size:104 url:] 
[2025-10-21 14:35:28] [WARNING]: 下载图片  时出现错误: Get "": unsupported protocol scheme "" 

应该是读取数据格式问题 我研究下怎么修复

@502647092
Copy link
Copy Markdown
Author

502647092 commented Oct 21, 2025

我研究了一下 好像之前的版本 get_image 就有问题吧
保存的数据结构

go-cqhttp/coolq/event.go

Lines 536 to 540 in ae92e97

data := binary.NewWriterF(func(w *binary.Builder) {
_, _ = w.Write(i.Md5)
w.WritePacketString(i.FileUUID, "u32", true)
w.WritePacketString(i.ImageID, "u32", true)
})

读取的数据结构

go-cqhttp/coolq/api.go

Lines 1143 to 1149 in ae92e97

r := binary.NewReader(b)
r.ReadBytes(16)
msg := global.MSG{
"size": r.ReadI32(),
"filename": r.ReadStringWithLength("u32", true),
"url": r.ReadStringWithLength("u32", true),
}

然后我试了下 2.0.0.beta.5 会直接G

2025/10/21 14:57:41 http: panic serving 127.0.0.1:43650: runtime error: slice bounds out of range [:1164464748] with capacity 160
goroutine 170 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1854 +0xbf
panic({0xa8ade0, 0xc0004505e8})
        runtime/panic.go:890 +0x263
github.com/LagrangeDev/LagrangeGo/utils/binary.(*Reader).ReadBytes(0xc0005f4900, 0x45685254)
        github.com/LagrangeDev/LagrangeGo@v0.1.4-0.20250216101915-d8933a0b7ce3/utils/binary/reader.go:143 +0xe5
github.com/LagrangeDev/LagrangeGo/utils/binary.(*Reader).ReadBytesWithLength(0xc0002b08f8?, {0xacb4b5, 0x3}, 0x1)
        github.com/LagrangeDev/LagrangeGo@v0.1.4-0.20250216101915-d8933a0b7ce3/utils/binary/reader.go:198 +0x131
github.com/LagrangeDev/LagrangeGo/utils/binary.(*Reader).ReadStringWithLength(0xa1caa0?, {0xacb4b5?, 0xacbdba?}, 0x4?)
        github.com/LagrangeDev/LagrangeGo@v0.1.4-0.20250216101915-d8933a0b7ce3/utils/binary/reader.go:202 +0x1e
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQGetImage(0x3?, {0xc00046c80f, 0x26})
        github.com/Mrs4s/go-cqhttp/coolq/api.go:1147 +0x365
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).call(0xc00013c5e0, {0xc00045058e, 0x9?}, 0xf68c20, {0xbca940, 0xc0000c8a20})
        github.com/Mrs4s/go-cqhttp/modules/api/api.go:183 +0x2d2b
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).Call(0xc00013c5e0, {0xc00045058e, 0x9}, 0x4d?, {0xbca940, 0xc0000c8a20})
        github.com/Mrs4s/go-cqhttp/modules/api/caller.go:35 +0xc5
github.com/Mrs4s/go-cqhttp/server.(*httpServer).ServeHTTP(0xc00013c5c0, {0xbceaf0, 0xc0002aa9a0}, 0xc00072f100)
        github.com/Mrs4s/go-cqhttp/server/http.go:213 +0x8ba
net/http.serverHandler.ServeHTTP({0xbcd280?}, {0xbceaf0, 0xc0002aa9a0}, 0xc00072f100)
        net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc0001e6990, {0xbcf150, 0xc00039fb90})
        net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
        net/http/server.go:3089 +0x5ed

@502647092
Copy link
Copy Markdown
Author

根据旧版 go-cqhttp 的相关代码
https://github.com/Mrs4s/go-cqhttp/blob/a5923f179b360331786a6509eb33481e775a7bd1/coolq/event.go#L663-L669
我临时修复了这个接口 旧数据反正也是炸的 暂时不管了 新的经过测试没问题了

@502647092
Copy link
Copy Markdown
Author

视频相关代码 经检查
保存部分

data := binary.NewBuilder().
WriteBool(source.SourceType == message.SourceGroup).
WriteBytes(i.Md5).
WriteBytes(i.Sha1).
WritePacketString(i.Name, "u32", true).
WritePacketString(i.UUID, "u32", true).
WriteU32(uint32(source.PrimaryID)).
ToBytes()

读取部分

r := binary.NewReader(b)
isGroup := r.ReadU8() == '1'
video := &message.ShortVideoElement{ // todo 检查缓存是否有效
  Md5:  r.ReadBytes(16),
  Sha1: r.ReadBytes(20),
  Name: r.ReadStringWithLength("u32", true),
  UUID: r.ReadStringWithLength("u32", true),
}
target := r.ReadU32()

顺序匹配 格式匹配 应该没问题

@502647092
Copy link
Copy Markdown
Author

消息撤回接口正常 消息保存应该是正常的

@502647092
Copy link
Copy Markdown
Author

获取聊天记录接口 get_group_msg_history 未返回数据 传递参数 message_seq 时报错

[2025-10-21 15:31:20] [WARNING]: 获取 0 成员信息失败尝试刷新成员列表 
2025/10/21 15:31:20 http: panic serving 127.0.0.1:60340: runtime error: invalid memory address or nil pointer dereference
goroutine 365 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1947 +0xbe
panic({0x9946e0?, 0xee3810?})
        runtime/panic.go:792 +0x132
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQGetGroupMessageHistory(0xc00044ed80, 0x2e0d0f0a, 0x2b96)
        github.com/Mrs4s/go-cqhttp/coolq/api.go:1321 +0x7df
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).call(0xc000020080, {0xc000024336, 0x15?}, 0xeea6e0, {0xb40c60, 0xc00061a3c0})
        github.com/Mrs4s/go-cqhttp/modules/api/api.go:175 +0x7da7
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).Call(0xc000020080, {0xc000024336, 0x15}, 0xeea6e0, {0xb40c60, 0xc00061a3c0})
        github.com/Mrs4s/go-cqhttp/modules/api/caller.go:35 +0xb3
github.com/Mrs4s/go-cqhttp/server.(*httpServer).ServeHTTP(0xc000020060, {0xb44f10, 0xc00048c0e0}, 0xc0003b63c0)
        github.com/Mrs4s/go-cqhttp/server/http.go:213 +0x665
net/http.serverHandler.ServeHTTP({0xb43038?}, {0xb44f10?, 0xc00048c0e0?}, 0x1?)
        net/http/server.go:3301 +0x8e
net/http.(*conn).serve(0xc00028a900, {0xb45810, 0xc0002f0cc0})
        net/http/server.go:2102 +0x625
created by net/http.(*Server).Serve in goroutine 85
        net/http/server.go:3454 +0x485

@Redmomn
Copy link
Copy Markdown
Collaborator

Redmomn commented Oct 21, 2025

获取聊天记录接口 get_group_msg_history 未返回数据 传递参数 message_seq 时报错

[2025-10-21 15:31:20] [WARNING]: 获取 0 成员信息失败尝试刷新成员列表 
2025/10/21 15:31:20 http: panic serving 127.0.0.1:60340: runtime error: invalid memory address or nil pointer dereference
goroutine 365 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1947 +0xbe
panic({0x9946e0?, 0xee3810?})
        runtime/panic.go:792 +0x132
github.com/Mrs4s/go-cqhttp/coolq.(*CQBot).CQGetGroupMessageHistory(0xc00044ed80, 0x2e0d0f0a, 0x2b96)
        github.com/Mrs4s/go-cqhttp/coolq/api.go:1321 +0x7df
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).call(0xc000020080, {0xc000024336, 0x15?}, 0xeea6e0, {0xb40c60, 0xc00061a3c0})
        github.com/Mrs4s/go-cqhttp/modules/api/api.go:175 +0x7da7
github.com/Mrs4s/go-cqhttp/modules/api.(*Caller).Call(0xc000020080, {0xc000024336, 0x15}, 0xeea6e0, {0xb40c60, 0xc00061a3c0})
        github.com/Mrs4s/go-cqhttp/modules/api/caller.go:35 +0xb3
github.com/Mrs4s/go-cqhttp/server.(*httpServer).ServeHTTP(0xc000020060, {0xb44f10, 0xc00048c0e0}, 0xc0003b63c0)
        github.com/Mrs4s/go-cqhttp/server/http.go:213 +0x665
net/http.serverHandler.ServeHTTP({0xb43038?}, {0xb44f10?, 0xc00048c0e0?}, 0x1?)
        net/http/server.go:3301 +0x8e
net/http.(*conn).serve(0xc00028a900, {0xb45810, 0xc0002f0cc0})
        net/http/server.go:2102 +0x625
created by net/http.(*Server).Serve in goroutine 85
        net/http/server.go:3454 +0x485

这个感觉像是lagrangego的问题,先不管他

@502647092
Copy link
Copy Markdown
Author

排查了一下 应该是消息被撤回之后导致的问题
"user_id": 0,
"message": "\u0026#91;已删除\u0026#93;",

@502647092
Copy link
Copy Markdown
Author

502647092 commented Oct 21, 2025

设置群禁言接口 set_group_whole_ban 在有权限的情况下 只能禁言 不能解除禁言

{
  "data": null,
  "message": "机器人权限不足",
  "msg": "NOT_MANAGEABLE",
  "retcode": 100,
  "status": "failed",
  "wording": "机器人权限不足"
}

根据代码逻辑 应该是 LagrangeGo 返回的失败

@502647092
Copy link
Copy Markdown
Author

群公告 _send_group_notice_get_group_notice 接口 请求失败
看起来也是 LagrangeGo 内部实现返回的错误

@Redmomn Redmomn merged commit 3f1e349 into LagrangeDev:master Oct 21, 2025
@502647092
Copy link
Copy Markdown
Author

删除群文件接口 delete_group_file 入参和标准文档不匹配
根据相关项目文档
https://docs.go-cqhttp.org/api/#%E5%88%A0%E9%99%A4%E7%BE%A4%E6%96%87%E4%BB%B6
https://napcat.apifox.cn/226658755e0
应该是

{
    "group_id": xxxx,
    "file_id": "xxxx"
}

但是实际实现获取的是id

case "delete_group_file":
    p0 := p.Get("group_id").Int()
    p1 := p.Get("id").String()
    return c.bot.CQGroupFileDeleteFile(p0, p1)

@502647092
Copy link
Copy Markdown
Author

大部分接口都测试过了 看起来没太大问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants